
             
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @File name:  TProductFavoritesDao.java 
 * @Create on:  2012-10-25 18:43:502
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        package com.boho.ecp.member.dao;

            
import java.sql.Connection;

import cn.boho.framework.po.CQuery;
import cn.boho.framework.po.CQueryFactoryTool;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.DAO;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.Pager;
            
/**
 * 【会员收藏商品信息:T_PRODUCT_FAVORITES】的Dao操作类
 * 
 */
public class TProductFavoritesDao extends DAO {
   
	/**
	* 分页查询所有【会员收藏商品信息:T_PRODUCT_FAVORITES】信息
	* @param con
	* @param pager
	* @return
	* @throws Exception
	* @date 2012-10-25
	* @author 陈伟
	*
	*/
	public static ComboPager queryTProductFavoritesByPager(Connection con,Pager pager, Integer memberId)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select p.PRODUCT_ID, p.PRODUCT_NO, p.PRODUCT_NAME, p.PHOTO_URL, p.MEMBER_PRICE, p.MARKET_PRICE,");
		sql.append(" f.PRODUCT_FAVORITES_ID, f.FAVORITES_DATE from T_PRODUCT_FAVORITES f, T_PRODUCT p");
		sql.append(" where f.PRODUCT_ID = p.PRODUCT_ID and f.IS_VALID = 1 and f.MEMBER_ID = ? order by f.FAVORITES_DATE desc");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setInt(1, memberId);
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_PRODUCT_FAVORITES", pager,con);
	}
	/**
	* 根据主键【会员收藏商品编号:PRODUCT_FAVORITES_ID|】获得信息
	* @param con
	* @param productFavoritesId 会员收藏商品编号
	* @return
	* @throws Exception
	* @date 2012-10-25
	* @author 陈伟
	*
	*/
	public static DynaBeanMap getTProductFavoritesByPk(Connection con, Integer productId, Integer memberId)throws Exception{
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PRODUCT_FAVORITES where PRODUCT_ID = ? and MEMBER_ID = ? and IS_VALID = 1");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1,productId);
		query.setInt(2, memberId);
		dynaBeanMap = query.getDynaBeanMap("T_PRODUCT_FAVORITES", con);
		return dynaBeanMap;
	}
}
